#ifndef PRODCONS_H_INCLUDED
#define PRODCONS_H_INCLUDED


#include "pthread.h"


// Internal struct: needed to free the gcg.h from depending on pthread.
typedef struct _SQS_PRODCONS {
  unsigned int counter;  // Object counter
  unsigned int prod_pos; // posicao que o produtor vai inserir no buffer
  unsigned int cons_pos; // posicao que o consumidor vai retirar do buffer
  pthread_mutex_t mutex_counter;
  pthread_mutex_t mutex_cond_prod;
  pthread_mutex_t mutex_cond_cons;
  pthread_cond_t prod_cond;
  pthread_cond_t cons_cond;
  char execute; // flag for execution
  char blockprod;
  char blockcons;
  unsigned int buf_size;
  void **buffer;
} SQS_PRODCONS;


void sqsCreate(unsigned int bufferlength);
char createBuffer(unsigned int bufferlength);
void destroyBuffer();
char put(void *val);
void * get();
unsigned int getCounter();
void setBlocking(char _blockprod,char _blockcons);


#endif // PRODCONS_H_INCLUDED
